package com.salesmonitoring.accounts.view;

import java.util.Date;

import javax.swing.table.AbstractTableModel;

@SuppressWarnings("serial")
public class ReportTableModel extends AbstractTableModel {
	
	String titles[] = new String[] { "Date Requested", "Original Customer", "Account #", "New Buyer",
									 "Warehouse", "Date Sold", "Model", "Engine #",
									 "Chassis #", "Date Repo", "Plate #", "ASMF #",
									 "Class", "Repair Shop"};
	

	@SuppressWarnings("rawtypes")
	Class types[] = new Class[] { String.class, String.class, Integer.class, String.class,
								  String.class, String.class, String.class, Integer.class,
								  Integer.class, String.class, String.class, Integer.class,
								  String.class, String.class};

	Object data[][];
	
	int numberOfReports;
    
    public ReportTableModel(int numberOfReports) {
    	
    	data = new Object[numberOfReports][titles.length];
    	
    	this.numberOfReports = numberOfReports;
    	for(int x = 0; x < this.numberOfReports; x++) {
    		for(int y = 0; y < this.titles.length; y++) {
    			data[x][y] = new String[][] { { null, null, null, null } };
    		}
    	}
    }

    public String[] getTitles() {
    	return titles;
    }
    
    public int getColumnCount() {
      
    	return titles.length;
    }

    public int getRowCount() {
      
    	return data.length;
    }

    public String getColumnName(int col) {
      
    	return titles[col];
    }

    public Object getValueAt(int row, int col) {
      
    	return data[row][col];
    }

    /*
     * JTable uses this method to determine the default renderer/ editor for
     * each cell. If we didn't implement this method, then the last column
     * would contain text ("true"/"false"), rather than a check box.
     */
	public Class getColumnClass(int c) {
      
    	return types[c];
    }

    /*
     * Don't need to implement this method unless your table's editable.
     */
    //public boolean isCellEditable(int row, int col) {
      //Note that the data/cell address is constant,
      //no matter where the cell appears onscreen.
      //if (col < 2) {
      //  return false;
      //} else {
      //  return true;
      //}
    //}

    /*
     * Don't need to implement this method unless your table's data can
     * change.
     */
    public void setValueAt(Object value, int row, int col) {
      
      data[row][col] = value;
      fireTableDataChanged();
      //fireTableCellUpdated(row, col);

    } 
}
